package org.eclipse.rally.plugin.views;

import java.io.File;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.Map;

import org.eclipse.rally.plugin.utils.RallyConstants;
import org.eclipse.rally.plugin.utils.SWTResourceManager;
import org.eclipse.rally.plugin.utils.FileViewer;
import org.eclipse.rally.plugin.webservice.RallyMain;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;

import com.rallydev.webservice.v1_12.domain.Attachment;
import com.rallydev.webservice.v1_12.domain.AttachmentContent;
import com.rallydev.webservice.v1_12.domain.Defect;


public class DefectDetailGUI {
    public static Shell shell;
    private static Button button;
    public static Composite composite ;
     public static ScrolledComposite scrolledComposite;
    public static Group group;
    public static Map attachmentMap;
     static String strAttachment = "";  
     static String taskObjRef = "";

    public static void main(String[] args) {
        Display display = new Display();
        shell = new Shell(display);
        shell.setMinimumSize(new Point(400, 1100));
        shell.setLayout(new FillLayout());
        String i="ref";
        String id = "DE5731";
        TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
        TabItem tbtmIssuedetail = new TabItem(tabFolder, SWT.NONE);
        tbtmIssuedetail.setText("Issue &Detail");
        new DefectDetailGUI().defectDetail(tabFolder, tbtmIssuedetail, id,i);
        
       
       
        
        shell.setSize(900, 700);
        shell.open();

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }

        display.dispose();
    }

    
    public Group defectDetail(final TabFolder tabFolder,final TabItem tabItem, final String defectRefrence,final String pageName) {
    	try{
    		System.out.println("entering into defectDetail****");
    	Defect defect = (Defect) RallyMain.readDefectObject(defectRefrence);
    	
         scrolledComposite = new ScrolledComposite(tabFolder, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    	tabItem.setControl(scrolledComposite);
    	scrolledComposite.setExpandHorizontal(true);
    	scrolledComposite.setExpandVertical(true);
    	
    	 composite = new Composite(scrolledComposite, SWT.BORDER);
    	composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_BACKGROUND));
       // tabItem.setControl(composite);
        group = new Group(composite, SWT.BORDER);
        group.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        group.setBounds(5, 5, 850, 1017);

        {
            Label lblGeneral = new Label(group, SWT.BORDER);
            lblGeneral.setForeground(SWTResourceManager.getColor(
                    SWT.COLOR_WIDGET_BORDER));
            lblGeneral.setBackground(SWTResourceManager.getColor(
                    SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
            lblGeneral.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.BOLD));
            lblGeneral.setBounds(0, 0, 168, 21);
            lblGeneral.setText("General");
        }

        Label lblId = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblId.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblId.setBounds(0, 20, 166, 21);
        lblId.setText("ID :");
        lblId.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblId.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblName = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblName.setBounds(0, 40, 166, 34);
        lblName.setText("Name :");
        lblName.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblName.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblName.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblDescription = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblDescription.setBounds(0, 74, 166, 232);
        lblDescription.setText("Description:");
        lblDescription.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblDescription.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblDescription.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblAttachments = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblAttachments.setBounds(0, 307, 166, 63);
        lblAttachments.setText("Attachments:");
        lblAttachments.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblAttachments.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblAttachments.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblOwner = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblOwner.setBounds(0, 370, 166, 21);
        lblOwner.setText("Owner:");
        lblOwner.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblOwner.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        lblOwner.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblProject = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblProject.setBounds(0, 390, 166, 21);
        lblProject.setText("Project:");
        lblProject.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblProject.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        lblProject.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        {
            Label label = new Label(group, SWT.SEPARATOR | SWT.VERTICAL);
            label.setForeground(SWTResourceManager.getColor(
                    SWT.COLOR_LIST_SELECTION));
            label.setBackground(SWTResourceManager.getColor(
                    SWT.COLOR_LIST_SELECTION));
            label.setBounds(166, 20, 2, 412);
        }

        Label lblDefect = new Label(group, SWT.BORDER);
        lblDefect.setBounds(0, 411, 168, 21);
        lblDefect.setText("Defect");
        lblDefect.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_WIDGET_BORDER));
        lblDefect.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.BOLD));
        lblDefect.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_BACKGROUND));

        Label lblState = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblState.setBounds(0, 431, 166, 21);
        lblState.setText("State:");
        lblState.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblState.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblState.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblPriority = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblPriority.setBounds(0, 471, 166, 21);
        lblPriority.setText("Submitted By:");
        lblPriority.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblPriority.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblPriority.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label priority = new Label(group, SWT.RIGHT);
        priority.setBounds(172, 452, 166, 21);
        priority.setForeground(SWTResourceManager.getColor(0, 0, 0));
        priority.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        priority.setBackground(SWTResourceManager.getColor(255, 255, 255));
        priority.setAlignment(SWT.LEFT);
        
        Label lblPriority_1 = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblPriority_1.setBounds(0, 452, 166, 21);
        lblPriority_1.setText("Priority:");
        lblPriority_1.setForeground(SWTResourceManager.getColor(0, 0, 0));
        lblPriority_1.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblPriority_1.setBackground(SWTResourceManager.getColor(216, 228, 248));
        
        
        
        Label lblFoundIn = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblFoundIn.setBounds(0, 491, 166, 21);
        lblFoundIn.setText("Found In:");
        lblFoundIn.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblFoundIn.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblFoundIn.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblTargetBuild = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblTargetBuild.setBounds(0, 529, 166, 21);
        lblTargetBuild.setText("Resolution:");
        lblTargetBuild.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblTargetBuild.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblTargetBuild.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblResolution = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblResolution.setBounds(0, 550, 166, 21);
        lblResolution.setText("Release Note:");
        lblResolution.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblResolution.setFont(SWTResourceManager.getFont("Tahoma", 10,
                SWT.NORMAL));
        lblResolution.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblReleaseNote = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblReleaseNote.setBounds(0, 571, 166, 21);
        lblReleaseNote.setText("User Story:");
        lblReleaseNote.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblReleaseNote.setFont(SWTResourceManager.getFont("Tahoma", 10,
                SWT.NORMAL));
        lblReleaseNote.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label label = new Label(group, SWT.SEPARATOR);
        label.setBounds(166, 411, 2, 180);
        label.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_SELECTION));
        label.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_SELECTION));

        Label lblSchedule = new Label(group, SWT.BORDER);
        lblSchedule.setBounds(0, 591, 168, 21);
        lblSchedule.setText("Schedule");
        lblSchedule.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_WIDGET_BORDER));
        lblSchedule.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.BOLD));
        lblSchedule.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_BACKGROUND));

        Label lblScheduleState = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblScheduleState.setBounds(0, 612, 166, 21);
        lblScheduleState.setText("Schedule State:");
        lblScheduleState.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblScheduleState.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblScheduleState.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblRelease = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblRelease.setBounds(0, 632, 166, 21);
        lblRelease.setText("Release:");
        lblRelease.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblRelease.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblRelease.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblPlanEstimate = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblPlanEstimate.setBounds(0, 652, 166, 21);
        lblPlanEstimate.setText("Plan Estimate:");
        lblPlanEstimate.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblPlanEstimate.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblPlanEstimate.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblToDo = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblToDo.setBounds(0, 672, 166, 21);
        lblToDo.setText("To Do:");
        lblToDo.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblToDo.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        lblToDo.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblTargetBuild_1 = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblTargetBuild_1.setBounds(0, 511, 166, 21);
        lblTargetBuild_1.setText("Target Build:");
        lblTargetBuild_1.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblTargetBuild_1.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblTargetBuild_1.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblActual = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblActual.setBounds(0, 692, 166, 21);
        lblActual.setText("Actual:");
        lblActual.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblActual.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        lblActual.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        System.out.println("before name check****");
        Browser browser = new Browser(group, SWT.BORDER);
        System.out.println(defect.getName());
        if(defect.getName() != null)
        	browser.setText(defect.getName().trim());
			else
				browser.setText("");
        browser.setBounds(172, 40, 600, 34);
		
        Browser lblValue = new Browser(group, SWT.BORDER);
        if(defect.getDescription() != null){
    		lblValue.setText(defect.getDescription());
    		}else
    			lblValue.setText("");
        lblValue.setBounds(172, 75, 600, 227);
		
      
         getAttachment(defect);
         
         ScrolledComposite scrolledComposite_1 = new ScrolledComposite(group, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
         scrolledComposite_1.setBounds(172, 307, 600, 60);
         scrolledComposite_1.setExpandHorizontal(true);
         scrolledComposite_1.setExpandVertical(true);
        
         Link link = new Link(scrolledComposite_1, SWT.BORDER |SWT.V_SCROLL|SWT.H_SCROLL);
         link.setText(strAttachment);
         link.addListener(SWT.Selection, new Listener() {
             public void handleEvent(Event event) {
            	 try{
            	 System.out.println("Event =="+event.text);
            	 String strFileName = event.text;
            	 Attachment attachment =  (Attachment)attachmentMap.get(strFileName);
            	 AttachmentContent content = getAttachmnetContent(attachment);
            	 byte[] fileBArray =  (byte[])content.getContent(); 
            	 FileOutputStream fos = new FileOutputStream(strFileName);
            	 fos.write(fileBArray);
            	 fos.close();
            	 File file = new File(strFileName);
            	 FileViewer.viewFile(file);
            	 }catch(Exception r){
            		 r.printStackTrace();
            	 }
             }
           });
         link.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
         link.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
         link.setBackground(SWTResourceManager.getColor(
                 SWT.COLOR_LIST_BACKGROUND));
         scrolledComposite_1.setContent(link);
         scrolledComposite_1.setMinSize(link.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  
    
        Label lblValue_4 = new Label(group, SWT.RIGHT);
        lblValue_4.setAlignment(SWT.LEFT);
        lblValue_4.setBounds(172, 370, 166, 21);
        if(defect.getOwner() != null)
        	lblValue_4.setText(defect.getOwner());
        	//lblValue_4.setText(defect.getOwner());
    		else
    			lblValue_4.setText("");	
        lblValue_4.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblValue_4.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        lblValue_4.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));

        Label lblValue_5 = new Label(group, SWT.RIGHT);
        lblValue_5.setAlignment(SWT.LEFT);
        lblValue_5.setBounds(172, 390, 166, 21);
        if (defect.getProject() != null
				&& defect.getProject().getRefObjectName() != null) {
			lblValue_5.setText(defect.getProject().getRefObjectName());
		} else
			lblValue_5.setText("");
        lblValue_5.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblValue_5.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        lblValue_5.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));

        Label label_1 = new Label(group, SWT.RIGHT);
        label_1.setBounds(172, 431, 166, 21);
        if(defect.getState() != null)
    		label_1.setText(defect.getState());
    		else
    			label_1.setText("");	
        label_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_1.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        label_1.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_1.setAlignment(SWT.LEFT);

        Label label_2 = new Label(group, SWT.RIGHT);
        label_2.setBounds(172, 471, 166, 21);
        if(defect.getSubmittedBy() != null)
    		label_2.setText(defect.getSubmittedBy());
    		else
    			label_2.setText("");	
        label_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_2.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_2.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_2.setAlignment(SWT.LEFT);

        Label label_3 = new Label(group, SWT.RIGHT);
        label_3.setBounds(172, 491, 166, 21);
        if(defect.getFoundInBuild() != null)
    		label_3.setText(defect.getFoundInBuild());
    		else
    			label_3.setText("");	
        label_3.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_3.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_3.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_3.setAlignment(SWT.LEFT);

        Label label_4 = new Label(group, SWT.RIGHT);
        label_4.setBounds(172, 529, 166, 21);
        if(defect.getResolution() != null)
    		label_4.setText(defect.getResolution());
    		else
    			label_4.setText("");
        label_4.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_4.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        label_4.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_4.setAlignment(SWT.LEFT);

        Label label_5 = new Label(group, SWT.RIGHT);
        label_5.setBounds(172, 549, 166, 21);
        if(defect.getReleaseNote() != null)
    		label_5.setText(String.valueOf(defect.getReleaseNote()));
    		else
    			label_5.setText("");
        label_5.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_5.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_5.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_5.setAlignment(SWT.LEFT);

        Label label_6 = new Label(group, SWT.RIGHT);
        label_6.setBounds(172, 569, 166, 21);
        label_6.setText("User Story");
        label_6.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_6.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_6.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_6.setAlignment(SWT.LEFT);

        Label label_7 = new Label(group, SWT.RIGHT);
        label_7.setBounds(172, 511, 166, 21);
        if (defect.getTargetBuild() != null)
			label_7.setText(defect.getTargetBuild());
		else
			label_7.setText("");
        label_7.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_7.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_7.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_7.setAlignment(SWT.LEFT);

        Label label_8 = new Label(group, SWT.RIGHT);
        label_8.setBounds(172, 612, 166, 21);
        if (defect.getScheduleState() != null)
			label_8.setText(defect.getScheduleState());
		else
			label_8.setText("");
        label_8.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_8.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        label_8.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_8.setAlignment(SWT.LEFT);

        Label label_9 = new Label(group, SWT.RIGHT);
        label_9.setBounds(172, 632, 166, 21);
        if (defect.getRelease() != null
				&& defect.getRelease().getName() != null)
			label_9.setText(defect.getRelease().getName());
		else
			label_9.setText("");
        label_9.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_9.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_9.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_9.setAlignment(SWT.LEFT);

        Label label_10 = new Label(group, SWT.RIGHT);
        label_10.setBounds(172, 652, 166, 21);
        if (defect.getPlanEstimate() != null)
			label_10.setText(String.valueOf(defect.getPlanEstimate()));
		else
			label_10.setText("");
        label_10.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_10.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_10.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_10.setAlignment(SWT.LEFT);

        Label label_11 = new Label(group, SWT.RIGHT);
        label_11.setBounds(172, 672, 166, 21);
        label_11.setText("To do");
        label_11.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_11.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_11.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_11.setAlignment(SWT.LEFT);

        Label label_12 = new Label(group, SWT.RIGHT);
        label_12.setBounds(172, 690, 166, 21);
        label_12.setText("Actual");
        label_12.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_12.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        label_12.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_12.setAlignment(SWT.LEFT);

        Label lblCustom = new Label(group, SWT.BORDER);
        lblCustom.setBounds(0, 714, 168, 21);
        lblCustom.setText("Custom");
        lblCustom.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_WIDGET_BORDER));
        lblCustom.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.BOLD));
        lblCustom.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_BACKGROUND));

        Label lblCitiSeverity = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblCitiSeverity.setBounds(0, 732, 166, 21);
        lblCitiSeverity.setText("Citi Severity:");
        lblCitiSeverity.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblCitiSeverity.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblCitiSeverity.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label label_14 = new Label(group, SWT.RIGHT);
        label_14.setBounds(172, 732, 166, 21);
        if(defect.getCitiSeverity() != null )
    		label_14.setText(defect.getCitiSeverity());
    		else
    			label_14.setText("");
        label_14.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_14.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        label_14.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_14.setAlignment(SWT.LEFT);

        Label lblClientdefectid = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblClientdefectid.setBounds(0, 752, 166, 21);
        lblClientdefectid.setText("ClientDefectID:");
        lblClientdefectid.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblClientdefectid.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblClientdefectid.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label label_16 = new Label(group, SWT.RIGHT);
        label_16.setBounds(172, 752, 166, 21);
        if(defect.getClientDefectID()!= null)
        	label_16.setText(defect.getClientDefectID());
    		else
    			label_16.setText("");
        label_16.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_16.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_16.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_16.setAlignment(SWT.LEFT);

        Label label_17 = new Label(group, SWT.SEPARATOR);
        label_17.setBounds(166, 612, 2, 100);
        label_17.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_SELECTION));
        label_17.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_SELECTION));

        Label lblEnvironment = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblEnvironment.setBounds(444, 451, 166, 21);
        lblEnvironment.setText("Environment:");
        lblEnvironment.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblEnvironment.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblEnvironment.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblSeverity = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblSeverity.setBounds(444, 471, 166, 21);
        lblSeverity.setText("Severity:");
        lblSeverity.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblSeverity.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblSeverity.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblCreationDate = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblCreationDate.setBounds(444, 491, 166, 21);
        lblCreationDate.setText("Creation Date:");
        lblCreationDate.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblCreationDate.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblCreationDate.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblFixedIn = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblFixedIn.setBounds(444, 511, 166, 21);
        lblFixedIn.setText("Fixed In:");
        lblFixedIn.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblFixedIn.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblFixedIn.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblVerifiedIn = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblVerifiedIn.setBounds(444, 529, 166, 21);
        lblVerifiedIn.setText("Verified In:");
        lblVerifiedIn.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblVerifiedIn.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblVerifiedIn.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblTargetDate = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblTargetDate.setBounds(444, 550, 166, 21);
        lblTargetDate.setText("Target Date:");
        lblTargetDate.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblTargetDate.setFont(SWTResourceManager.getFont("Tahoma", 10,
                SWT.NORMAL));
        lblTargetDate.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblAffectsDoc = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblAffectsDoc.setBounds(444, 571, 166, 21);
        lblAffectsDoc.setText("Affects Doc:");
        lblAffectsDoc.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblAffectsDoc.setFont(SWTResourceManager.getFont("Tahoma", 10,
                SWT.NORMAL));
        lblAffectsDoc.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label label_18 = new Label(group, SWT.SEPARATOR);
        label_18.setBounds(610, 451, 2, 140);
        label_18.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_SELECTION));
        label_18.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_SELECTION));

        Label label_19 = new Label(group, SWT.RIGHT);
        label_19.setBounds(615, 451, 166, 21);
        if (defect.getEnvironment() != null)
			label_19.setText(defect.getEnvironment());
		else
			label_19.setText("");
        label_19.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_19.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        label_19.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_19.setAlignment(SWT.LEFT);

        Label label_20 = new Label(group, SWT.RIGHT);
        label_20.setBounds(615, 473, 166, 21);
        label_20.setText("Value20");
        label_20.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_20.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_20.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_20.setAlignment(SWT.LEFT);

        Label label_21 = new Label(group, SWT.RIGHT);
        label_21.setBounds(615, 493, 166, 21);
        if(defect.getSeverity() != null)
    		label_21.setText(defect.getSeverity());
    		else
    			label_21.setText("");
        label_21.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_21.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_21.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_21.setAlignment(SWT.LEFT);

        Label label_22 = new Label(group, SWT.RIGHT);
        label_22.setBounds(615, 513, 166, 21);
        if(defect.getFixedInBuild() != null)
    		label_22.setText(defect.getFixedInBuild());
    		else
    			label_22.setText("");	
        label_22.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_22.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_22.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_22.setAlignment(SWT.LEFT);

        Label label_23 = new Label(group, SWT.RIGHT);
        label_23.setBounds(615, 531, 166, 21);
        if(defect.getVerifiedInBuild() != null)
    		label_23.setText(defect.getVerifiedInBuild());
    		else
    			label_23.setText("");
        label_23.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_23.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        label_23.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_23.setAlignment(SWT.LEFT);

        Label label_24 = new Label(group, SWT.RIGHT);
        label_24.setBounds(615, 551, 166, 21);
        if(defect.getTargetDate() != null)
    		label_24.setText(String.valueOf(defect.getTargetDate()));
    		else
    			label_24.setText("");	
        label_24.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_24.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_24.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_24.setAlignment(SWT.LEFT);

        Label label_25 = new Label(group, SWT.RIGHT);
        label_25.setBounds(615, 571, 166, 21);
        if(defect.getAffectsDoc() != null)
    		label_25.setText(String.valueOf(defect.getAffectsDoc()));
    		else
    			label_25.setText("");
        label_25.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_25.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_25.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_25.setAlignment(SWT.LEFT);

        Label label_26 = new Label(group, SWT.BORDER);
        label_26.setBounds(170, 17, 800, 3);
        label_26.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_WIDGET_BORDER));
        label_26.setFont(SWTResourceManager.getFont("Times New Roman", 13,
                SWT.BOLD));
        label_26.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_BACKGROUND));

        Label label_27 = new Label(group, SWT.RIGHT);
        label_27.setBounds(172, 20, 166, 21);
        if(defect.getFormattedID() != null)
    		label_27.setText(defect.getFormattedID());
    		else
    			label_27.setText("");	
        label_27.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_27.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        label_27.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_27.setAlignment(SWT.LEFT);

        Label label_28 = new Label(group, SWT.BORDER);
        label_28.setBounds(160, 428, 800, 3);
        label_28.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_WIDGET_BORDER));
        label_28.setFont(SWTResourceManager.getFont("Times New Roman", 13,
                SWT.BOLD));
        label_28.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_BACKGROUND));

        Label label_29 = new Label(group, SWT.BORDER);
        label_29.setBounds(160, 609, 800, 3);
        label_29.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_WIDGET_BORDER));
        label_29.setFont(SWTResourceManager.getFont("Times New Roman", 13,
                SWT.BOLD));
        label_29.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_BACKGROUND));

        Label label_30 = new Label(group, SWT.BORDER);
        label_30.setBounds(160, 729, 800, 3);
        label_30.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_WIDGET_BORDER));
        label_30.setFont(SWTResourceManager.getFont("Times New Roman", 13,
                SWT.BOLD));
        label_30.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_BACKGROUND));

        Label lblBlocked = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblBlocked.setBounds(444, 612, 166, 21);
        lblBlocked.setText("Blocked:");
        lblBlocked.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblBlocked.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblBlocked.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblIteration = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblIteration.setBounds(444, 632, 166, 21);
        lblIteration.setText("Iteration:");
        lblIteration.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblIteration.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblIteration.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label lblTaskEstimate = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblTaskEstimate.setBounds(444, 652, 166, 21);
        lblTaskEstimate.setText("Task Estimate:");
        lblTaskEstimate.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblTaskEstimate.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblTaskEstimate.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label label_31 = new Label(group, SWT.RIGHT);
        label_31.setBounds(615, 612, 166, 21);
        if(defect.getBlocked() != null)
    		label_31.setText(String.valueOf(defect.getBlocked()));
    		else
    			label_31.setText("");
        label_31.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_31.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        label_31.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_31.setAlignment(SWT.LEFT);

        Label label_32 = new Label(group, SWT.RIGHT);
        label_32.setBounds(615, 632, 166, 21);
        if (defect.getIteration() != null
				&& defect.getIteration().getName() != null)
			label_32.setText(defect.getIteration().getName());
		else
			label_32.setText("");
        label_32.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_32.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_32.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_32.setAlignment(SWT.LEFT);

        Label label_33 = new Label(group, SWT.RIGHT);
        label_33.setBounds(615, 652, 166, 21);
        if(defect.getTaskEstimateTotal()!= null)
    		label_33.setText(String.valueOf(defect.getTaskEstimateTotal()));
    		else
    			label_33.setText("");
        label_33.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_33.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_33.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_33.setAlignment(SWT.LEFT);

        Label label_34 = new Label(group, SWT.SEPARATOR);
        label_34.setBounds(610, 612, 2, 61);
        label_34.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_SELECTION));
        label_34.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_SELECTION));

        ///////
        Label lblCorrectiveActionca = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblCorrectiveActionca.setBounds(0, 772, 166, 21);
        lblCorrectiveActionca.setText("Corrective Action (CA): ");
        lblCorrectiveActionca.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblCorrectiveActionca.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblCorrectiveActionca.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label label_36 = new Label(group, SWT.RIGHT);
        label_36.setBounds(172, 773, 166, 21);
        if(defect.getCorrectiveActionCA()!= null)
        	label_36.setText(defect.getCorrectiveActionCA());
    		else
    			label_36.setText("");
        label_36.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_36.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_36.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_36.setAlignment(SWT.LEFT);

        Label lblPreventiveActionspa = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblPreventiveActionspa.setBounds(0, 792, 166, 21);
        lblPreventiveActionspa.setText("Preventive Actions (PA):");
        lblPreventiveActionspa.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblPreventiveActionspa.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblPreventiveActionspa.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label label_15 = new Label(group, SWT.RIGHT);
        label_15.setBounds(172, 794, 166, 21);
        if(defect.getPreventiveActionsPA()!= null)
        	label_15.setText(defect.getPreventiveActionsPA());
    		else
    			label_15.setText("");
        label_15.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_15.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_15.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_15.setAlignment(SWT.LEFT);

        Label lblReopenStatus = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblReopenStatus.setBounds(0, 812, 166, 21);
        lblReopenStatus.setText("Re-Open Status:");
        lblReopenStatus.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_BLACK));
        lblReopenStatus.setFont(SWTResourceManager.getFont("Tahoma", 9,
                SWT.NORMAL));
        lblReopenStatus.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label label_37 = new Label(group, SWT.RIGHT);
        label_37.setBounds(172, 813, 166, 21);
        if(defect.getReOpenStatus()!= null)
        	label_37.setText(String.valueOf(defect.getReOpenStatus()));
    		else
    			label_37.setText("");
        label_37.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_37.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_37.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_37.setAlignment(SWT.LEFT);

        Label lblNotes = new Label(group, SWT.BORDER);
        lblNotes.setBounds(0, 832, 168, 21);
        lblNotes.setText("Notes");
        lblNotes.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_WIDGET_BORDER));
        lblNotes.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.BOLD));
        lblNotes.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_BACKGROUND));

        Label label_35 = new Label(group, SWT.BORDER);
        label_35.setBounds(160, 847, 800, 3);
        label_35.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_WIDGET_BORDER));
        label_35.setFont(SWTResourceManager.getFont("Times New Roman", 13,
                SWT.BOLD));
        label_35.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_BACKGROUND));

        Label lblRootCause = new Label(group, SWT.RIGHT);
        lblRootCause.setBounds(444, 812, 166, 21);
        lblRootCause.setText("Root Cause:");
        lblRootCause.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblRootCause.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblRootCause.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label label_13 = new Label(group, SWT.RIGHT);
        label_13.setBounds(615, 812, 166, 21);
       if(defect.getRootCause()!= null)
        	label_13.setText(defect.getRootCause());
    		else
    			label_13.setText("");
        label_13.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        label_13.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
        label_13.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_BACKGROUND));
        label_13.setAlignment(SWT.LEFT);

        Label lblNotes_1 = new Label(group, SWT.BORDER | SWT.RIGHT);
        lblNotes_1.setBounds(0, 852, 166, 161);
        lblNotes_1.setText("Notes :");
        lblNotes_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
        lblNotes_1.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
        lblNotes_1.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

        Label label_38 = new Label(group, SWT.SEPARATOR);
        label_38.setBounds(166, 732, 2, 100);
        label_38.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_SELECTION));
        label_38.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_SELECTION));

        Label label_39 = new Label(group, SWT.SEPARATOR);
        label_39.setBounds(166, 851, 2, 162);
        label_39.setForeground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_SELECTION));
        label_39.setBackground(SWTResourceManager.getColor(
                SWT.COLOR_LIST_SELECTION));
		
		 Browser notes = new Browser(group, SWT.BORDER);
		 if(defect.getNotes()!= null)
	        	notes.setText(defect.getNotes());
	    		else
	    			notes.setText("");
	        notes.setBounds(172, 856, 600, 157);
                
               final Label edit_label = new Label(group, SWT.NONE);
                       edit_label.setBackground(SWTResourceManager.getColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
                               edit_label.setImage(SWTResourceManager.getImage(DefectDetailGUI.class, "/icons/Button-Edit.gif"));
                                       edit_label.setBounds(732, 0, 40, 19);
                                               edit_label.addMouseTrackListener(new MouseTrackAdapter() {
                                       			@Override
                                       			public void mouseHover(MouseEvent e) {
                                       				final Cursor cursor = new Cursor(Display.getCurrent(),
                                       						SWT.CURSOR_HAND);
                                       
                                       				edit_label.setCursor(cursor);
                                       
                                       			}
                                       		});
                                                       edit_label.addMouseListener(new MouseAdapter() {
                                               			@Override
                                               			public void mouseDown(MouseEvent e) {
                                                               composite.dispose();
                                                               group.dispose();
                                                             //  if(i==1)
                                                               	 EditDefectDetailGUI.editdefectDetail(tabFolder, tabItem,defectRefrence,pageName);//backToDashboardPage(tabItem,tabFolder);
                                                              // else
                                                               //	new DefectsTabGUI().backToDefectPage(tabItem,tabFolder);	
                                                               }
                                               		});
                {
                	final Label back = new Label(group, SWT.NONE);
                	back.setBackground(SWTResourceManager.getColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
                	back.setImage(SWTResourceManager.getImage(DefectDetailGUI.class, "/icons/Back-enabled.gif"));
                	back.setBounds(800, 0, 48, 19);
                	back.addMouseTrackListener(new MouseTrackAdapter() {
        				@Override
        				public void mouseHover(MouseEvent e) {
        					final Cursor cursor = new Cursor(Display.getCurrent(),
        							SWT.CURSOR_HAND);
        
        					back.setCursor(cursor);
        
        				}
        			});
                	back.addMouseListener(new MouseAdapter() {
        				@Override
        				public void mouseDown(MouseEvent e) {
                            composite.dispose();
                            group.dispose();
                           if(pageName != null && pageName.equalsIgnoreCase(RallyConstants.PAGE_DEFECTS)) {
                        	   new DefectsTabGUI().backToDefectPage(tabItem,tabFolder);
        					}else if(pageName != null && pageName.equalsIgnoreCase(RallyConstants.PAGE_DASHBOARD)){
        						 new DashboardGUI().backToDashboardPage(tabItem,tabFolder);
        					}else if(pageName != null && pageName.equalsIgnoreCase(RallyConstants.PAGE_TASK_DETAILS)){
        						new TaskDetailGUI().backToTaskDetailPage(tabFolder, tabItem, taskObjRef, pageName);
        					}
                            		
                        }
        			});
                }
	        

        {
        	Label blue_label = new Label(group, SWT.NONE);
        	blue_label.setBounds(165, 0, 684, 20);
        	blue_label.setBackground(SWTResourceManager.getColor(122, 150, 223));	
        }
        scrolledComposite.setContent(composite);
    	scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    	}catch(Exception e){
        	e.printStackTrace();
        }
        return group;
    }
    
    
    public static void getAttachment(Defect defect){
    	 attachmentMap = new HashMap();
         strAttachment = "";
         if(defect.getAttachments() != null){
         Attachment[] attachment =  defect.getAttachments();
         int count = 1;
         for(Object obj:attachment){
         	Attachment attach = (Attachment)obj;
         	attach = (Attachment)RallyMain.readAttachemntObject(attach.getRef());
         	strAttachment += count+") <A>"+attach.getName()+"</A> \n";
         	attachmentMap.put(attach.getName(),attach);  
         	count ++;
         }
     
         }	
    }
    
    public AttachmentContent getAttachmnetContent(Attachment attachment){
    	AttachmentContent content = (AttachmentContent)RallyMain.readAttachemntContentObject(attachment.getContent().getRef());
    	  return content;
    }
    
    public static void goToDefectDetails(TabFolder tabFolder, TabItem tabItem,
			String DefectRefrence, String pageName,String taskRef){
    	
    	taskObjRef = taskRef;
    	new DefectDetailGUI().defectDetail(tabFolder,tabItem,DefectRefrence,pageName);
    	
    }
    
}
